const arr = [1, 2];
const string = "123";
const string2 = new String("123");

function myinstanceof(arr, type) {
  const proto = arr.__proto__;
  if (proto === type.prototype) {
    return true;
  } else {
    if (proto) {
      return myinstanceof(proto, type);
    }
  }
  return false;
}

console.log(myinstanceof(arr, Array))
console.log(myinstanceof(arr, Object))
console.log(myinstanceof(string, Array))
console.log(myinstanceof(string2, Array))
console.log(myinstanceof(string2, Object))